{include file="public/layout" /}
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    {include file="tools/bar" /}
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li> 数据还原, 点击恢复选项进行数据库导入.</li>
            <li> 导入的SQL文件语句必须按照MYSQL的语法编写</li>
        </ul>
    </div>
    <div class="flexigrid">
        
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc"><input type="checkbox" autocomplete="off" class="checkAll"></div>
                        </th>
                        <th abbr="article_title" axis="col3" class="">
                            <div class="tl text-l10">文件名称</div>
                        </th>
                        <th abbr="article_show" axis="col5" class="w100">
                            <div class="tc">系统版本</div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w40">
                            <div class="tc">卷号</div>
                        </th>
                        <th abbr="article_show" axis="col5" class="w60">
                            <div class="tc">压缩</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">数据大小</div>
                        </th>
                        <th abbr="article_show" axis="col7" class="w160">
                            <div class="tc">备份时间</div>
                        </th>
                       
                        <th axis="col1" class="w160">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr data-id="{$vo.basename}">
                            <td class="sign">
                                <div class="w40 tc"><input type="checkbox" autocomplete="off" name="ids[]" value="{$vo.time}"></div>
                            </td>
                            <td style="width: 100%">
                                <div class="tl text-l10" >{$vo.basename}</div>
                            </td>
                            <td>
                                <div class="w100 tc">{$vo.version}</div>
                            </td>
                            <td class="">
                                <div class="w40 tc">{$vo.part}</div>
                            </td>
                            <td>
                                <div class="w60 tc">{$vo.compress}</div>
                            </td>
                            <td>
                                <div class="w100 tc">{$vo.size|format_bytes}</div>
                            </td>
                            <td>
                                <div class="w160 tc">{$vo.time|date="Y-m-d H:i:s",###}</div>
                            </td>
                           
                            <td class="operation">
                                <div class="w160 tc">
                                    {eq name="$Think.const.CONTROLLER_NAME.'@new_import'|is_check_access" value="1"}
                                    <a href="javascript:void(0);" data-url="{:U('Tools/new_import', array('time'=>$vo['time']))}" class="btn blue db-import">恢复</a>
                                    {/eq}
                                    {eq name="$Think.const.CONTROLLER_NAME.'@downFile'|is_check_access" value="1"}
									<i></i>
                                    <a href="{:U('Tools/downFile',array('time'=>$vo['time']))}" class="btn green">下载</a>
                                    {/eq}
                                    {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
									<i></i>
                                    <a class="btn red"  href="javascript:void(0);" data-url="{:U('Tools/del')}" data-id="{$vo.time}" onClick="delfun(this);">删除</a>
                                    {/eq}
                                </div>
                            </td>
                          
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" autocomplete="off" class="checkAll">
                </div>
                {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                <div class="fbutton">
                    <a onclick="batch_del(this, 'ids');" data-url="{:U('Tools/del')}" class="layui-btn layui-btn-primary">
                            <span>批量删除</span>
                    </a>
                </div>
                {/eq}
                {eq name="$Think.const.CONTROLLER_NAME.'@restoreUpload'|is_check_access" value="1"}
                <div class="fbutton" style="display: none;">
                    <form class="navbar-form form-inline" action="{:U('Tools/restoreUpload')}" name="change_System" id="change_System" method="post" enctype="multipart/form-data">
                        <a href="javascript:void(0);" class="a-upload"><input type="file" name="sqlfile" id="sqlfile" title="请选择…"><i class="fa fa-upload"></i>上传执行sql文件</a>
                    </form>
                </div>
                {/eq}
				<div class="fbuttonr" style="margin-right: 15px;">
					<div class="total">
						 <h5>备份文件数量：{$filenum}，占空间大小：{$total|format_bytes}</h5>
					</div>
				</div>
				
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
</div>
<form class="none" name="form_tmp" id="form_tmp" action="" method="POST">

</form>
<script>
    $(function(){
        $('input[name*=ids]').click(function(){
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });
    });
    
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });

        $('#sqlfile').change(function(){
            restoreUpload();
        });
    
        function restoreUpload()
        {
            var sqlfile = $('input[name=sqlfile]').val();
            var ext = sqlfile.substr(sqlfile.lastIndexOf('.')).toLowerCase();
            if ($.trim(sqlfile) == '' || ext != '.sql') {
                showErrorMsg('请上传sql文件！');
                return false;
            }

            layer.confirm('此操作不可恢复，确认执行？', {
                title: false,//'<font color="red">重要提示</font>',
                btn: ['确定', '取消'] //按钮
            }, function () {
                layer_loading('正在处理');
                $('#change_System').submit();
                return false;
            }, function (index) {
                $('#sqlfile').val('');
                layer.closeAll();
                return false;
            });
        }

    });

    $(".db-import").click(function(){
        var url = $(this).attr('data-url');
        $('#form_tmp').attr('action', url);
        layer_loading('正在处理');
        $('#form_tmp').submit();
    });
</script>

{include file="public/footer" /}